<template>
	<view class="index">
		<view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item)">
			<view class="title">
				{{ item.title }}
			</view>
			<view class="info-wrapper">
				<view class="date">
					{{ item.createTime }}
				</view>
				<view class="author">
					{{ item.createBy }}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		mounted() {
			this.getNotice()
		},
		methods: {
			goDetail(item) {
				uni.navigateTo({
					url: '/subPage_notice/detail?id=' + item.id
				})
			},
			async getNotice() {
				const data = await this.$api.post('/app/notice/page', {
					noticeType: 2,
					pageNum: 1,
					pageSize: 100,
					orders: [{
						"asc": false,
						"column": "noticeId"
					}],
				})
				if (data.code === 200) {
					this.list = data.data.records.map(item => {
						return {
							id: item.noticeId,
							title: item.noticeTitle,
							createTime: item.createTime,
							createBy: item.createBy
						}
					});
				}
			},
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		overflow: auto;
		padding-bottom: 50upx;

		.item {
			background-color: #fff;
			padding: 30upx 30upx;
			margin-top: 10upx;

			.title {
				font-size: 32upx;
				font-weight: bold;
				width: 100%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.info-wrapper {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 28upx;
				color: #666666;
				margin-top: 30upx;
			}
		}
	}
</style>